package com.butuh.uang.tuh.ang.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.butuh.uang.tuh.ang.R;
import com.butuh.uang.tuh.ang.model.HomeListBean;
import com.butuh.uang.tuh.ang.model.ProductDetailBean;
import com.butuh.uang.tuh.ang.util.DecimalFormatUtil;

import cn.droidlover.xdroidmvp.base.XListAdapter;

public class DetailDesAdapter extends XListAdapter<ProductDetailBean.BesidesBean.TerperinciBean> {

    public DetailDesAdapter(Context context) {
        super(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHloder viewHloder;
        if (convertView == null) {
            viewHloder = new ViewHloder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_detail_des, null);
            viewHloder.iv_icon_application = convertView.findViewById(R.id.iv_icon_application);
            viewHloder.tv_app_name = convertView.findViewById(R.id.tv_app_name);
            viewHloder.tv_app_message = convertView.findViewById(R.id.tv_app_message);
            convertView.setTag(viewHloder);
        } else {
            viewHloder = (ViewHloder) convertView.getTag();
        }
        ProductDetailBean.BesidesBean.TerperinciBean bean = data.get(position);
        if (!TextUtils.isEmpty(bean.getIkon())) {
            viewHloder.iv_icon_application.setVisibility(View.VISIBLE);
            Glide.with(context).load(bean.getIkon()).into(viewHloder.iv_icon_application);
        } else {
            viewHloder.iv_icon_application.setVisibility(View.INVISIBLE);
        }
        viewHloder.tv_app_name.setText(bean.getCaption());
        viewHloder.tv_app_message.setText(bean.getDetails());
        return convertView;
    }

    class ViewHloder {
        ImageView iv_icon_application;
        TextView tv_app_name;
        TextView tv_app_message;
    }

}
